﻿using GylCSharpUtils.Common.Abstract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace GylCSharpUtils.GSerializer.Abstract {
    public abstract class AGSerializer : ASerializer {

        public static readonly BindingFlags GSFieldBindFlag = BindingFlags.Public | BindingFlags.Instance;


        public static string GetTypeName(Type type) {
            if(type == null) return null;
            var sa = type.AssemblyQualifiedName.Split(',');
            return String.Format($"{sa[1].Trim()},{sa[0]}");
        }
        public static void PraesTypeName(string templateTypeName, out string assemblyName, out string classFullName) {
            if(templateTypeName == null) throw new ArgumentNullException("参数TemplateTypeName不可为空");
            var sa = templateTypeName.Split(',');
            if(sa.Length != 2) throw new ArgumentException("模板类型名格式不正确，应为[assemblyName,classFullName]");
            assemblyName = sa[0];
            classFullName = sa[1];
        }

    }
}
